# File    :   docker-install-latest.sh
# Time    :   2023/06/07 17:49:26
# Author  :   Liu JC
# Version :   1.0
# Contact :   liujc.255@qq.com
# Desc    :   Copy from https://docs.docker.com/engine/install/ubuntu/

# Uninstall old versions🔗
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do apt-get remove $pkg; done

# Set up the repository
## 1. Update the apt package index and install packages to allow apt to use a repository over HTTPS:
apt-get update
apt-get install ca-certificates curl gnupg

## 2. Add Docker’s official GPG key:
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg

## 3. Use the following command to set up the repository:
echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian buster stable" | \
  tee /etc/apt/sources.list.d/docker.list > /dev/null

# Install Docker Engine

apt-get update
## 1. Install Docker Engine, containerd, and Docker Compose.
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

## 2. Verify that the Docker Engine installation is successful by running the hello-world image.
docker run hello-world
